package guowenlong.golf.ui.friendlymatch;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.OnClick;
import guowenlong.golf.R;
import guowenlong.golf.ui.friendlymatch.ResultTableSettingEntity.User;
import java.util.ArrayList;
import me.wenlong.mixutils.mvp.BaseActivity;

/**
 * des   : 描述
 * author: Administrator
 * email : guowenlong20000@gmail.com
 * time  : 2017年05月07日 下午 10:40.
 */

public class ResulteTableActivity extends BaseActivity {

  @BindView(R.id.tv_back)
  TextView tvBack;
  @BindView(R.id.tv_dao_result_table)
  TextView tvDaoResultTable;
  @BindView(R.id.rv_result_table)
  RecyclerView rvResultTable;
  @BindView(R.id.tv_special_result_table)
  TextView tvSpecialResultTable;
  @BindView(R.id.tv_result_table)
  TextView tvResultTable;
  @BindView(R.id.tv_input_result_table)
  TextView tvInputResultTable;
  @BindView(R.id.lv_result_table)
  ListView lvResultTable;
  private ResultTableAdapter mAdapter;
  private ResultTableSettingEntity resultTableSettingEntity;
  private ArrayList<ResultTableEntity> resultTableEntities;

  @Override
  protected int getContentView(Bundle savedInstanceState) {
    return R.layout.activity_result_table;
  }

  @Override
  protected void initView(Bundle savedInstanceState) {
    //设置布局管理器
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    rvResultTable.setLayoutManager(linearLayoutManager);
  }

  class UsersAdapter extends BaseAdapter {

    private ArrayList<User> mUsers;

    public UsersAdapter(ArrayList<User> users) {
      this.mUsers = users;
    }

    @Override
    public int getCount() {
      return mUsers.size();
    }

    @Override
    public Object getItem(int position) {
      return null;
    }

    @Override
    public long getItemId(int position) {
      return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      if (convertView == null){
        convertView = View.inflate(ResulteTableActivity.this,R.layout.item_lv_users,null);
      }
      return convertView;
    }
  }

  @Override
  protected void initData() {
    resultTableSettingEntity = new ResultTableSettingEntity();
    resultTableSettingEntity.setTitle1("球洞");
    resultTableSettingEntity.setTitle1("标准杆");
    User user1 = new User("张三");
    User user2 = new User("李四");
    User user3 = new User("王五");
    User user4 = new User("赵六");
    ArrayList<User> users = new ArrayList<>();
    users.add(user1);
    users.add(user2);
    users.add(user3);
    users.add(user4);
    resultTableSettingEntity.setUsers(users);
    resultTableEntities = new ArrayList<>();
    for (int i = 0; i < 18; i++) {
      resultTableEntities.add(new ResultTableEntity());
    }
    mAdapter = new ResultTableAdapter(this, resultTableEntities);
    rvResultTable.setAdapter(mAdapter);
    lvResultTable.setAdapter(new UsersAdapter(users));
  }

  @OnClick({R.id.tv_back, R.id.tv_dao_result_table, R.id.tv_special_result_table,
      R.id.tv_result_table, R.id.tv_input_result_table})
  public void onViewClicked(View view) {
    switch (view.getId()) {
      case R.id.tv_back:
        finish();
        break;
      case R.id.tv_dao_result_table:
        break;
      case R.id.tv_special_result_table:
        break;
      case R.id.tv_result_table:
        break;
      case R.id.tv_input_result_table:
        break;
    }
  }
}